using UnityEngine;

public class ButPromoAction : MonoBehaviour
{
	public GameObject butObj;

	public GameObject objImage;

	private void OnDisable()
	{
		if (ReplacePerelivController.instance != null)
		{
			ReplacePerelivController.bannerNeedShow -= ActivateButton;
		}
	}

	private void OnEnable()
	{
		if (ReplacePerelivController.instance != null)
		{
			ReplacePerelivController.bannerNeedShow += ActivateButton;
		}
		if (ReplacePerelivController.instance != null)
		{
			ActivateButton(ReplacePerelivController.needShowButtonGold);
		}
	}

	public void ActivateButton(bool val)
	{
		if (BCWDebug.isDebugBuild)
		{
			BCWDebug.Log("ActivateButtonPromo: " + val);
		}
		if (!(butObj != null))
		{
			return;
		}
		if (!val)
		{
			butObj.SetActive(false);
			if (objImage != null)
			{
				objImage.SetActive(false);
			}
		}
		if (val)
		{
			butObj.SetActive(true);
			if (objImage != null)
			{
				objImage.SetActive(true);
			}
		}
	}

	public void ShowPromoWindow()
	{
		if (ReplacePerelivController.instance != null)
		{
			ReplacePerelivController.instance.ShowWindows();
		}
	}
}
